package com.hsq.ndmall.wx.redis;

import cn.hutool.core.util.ObjectUtil;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * @author 黄四清
 * @version 1.0.0
 * @ClassName MyRedis.java
 * @Description TODO 自定义密钥生成规则
 * @createTime 2021年08月17日 16:37:00
 */
@Component
public class MyRedis implements KeyGenerator {

    @Override
    public Object generate(Object o, Method method, Object... objects) {
        StringBuffer s = new StringBuffer(o.getClass().getSimpleName() + "_" + method.getName());
        if (ObjectUtil.isNotEmpty(objects)) {
           s.append("objects.getClass().getName()");
        }
        return s;
    }
}
